package Waya::Bounds;

use warnings;
use strict;

use base 'Waya::Base';

__PACKAGE__->mk_scalar_accessors(qw(left right top bottom));


sub width {
    my $self = shift;
    $self->right - $self->left + 1;
}


sub height {
    my $self = shift;
    $self->bottom - $self->top + 1;
}


sub covers_whole_board_of_size {
    my ($self, $size) = @_;

    # be flexible
    if (ref $size eq 'Waya::SGF') { $size = $size->size }

    return
           $self->left   == 1
        && $self->right  == $size
        && $self->top    == 1
        && $self->bottom == $size;
}


1;
